<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <head th:include="common/common_head :: commonHead('我的账户')"></head>
</head>
<body class="larry-bg-gray">
<div class="larry-fluid">
    <div class="larry-container larryms-admin">
        <div class="larry-row larry-col-space20">
            <div class="larry-col-xs12 larry-col-sm4 larry-col-md3 larry-col-lg3 animated fadeInUp">
                <section class="larry-panel">
                    <div class="admin-info">
                        <div class="photo">
                            <img id="avatar" th:src="@{/static/larryms/images/user.jpg}"/>
                        </div>
                        <h3 class="larryms-user" th:text="${user?.userAccount}"></h3>
                        <p class="login-tie" align="center">上次登录：<span th:text="${lastVisit}"></span></p>
                    </div>
                </section>
            </div>
            <div class="larry-col-xs12 larry-col-sm8 larry-col-md9 larry-col-lg9 animated fadeInRightBig">
                <section class="larry-panel">
                    <div class="larryms-page-header">
                        <span class="tit">我的账户信息</span>
                    </div>
                    <div class="larryms-page-body">
                        <form class="layui-form" id="myPanel">
                            <div class="larry-form-item">
                                <label class="larry-form-label">登录账号</label>
                                <div class="larry-input-block">
                                    <input type="text" id="userAccount" name="userAccount" autocomplete="off"
                                           class="layui-input larry-input" th:value="${user?.userAccount}" readonly="readonly"/>
                                </div>
                            </div>
                            <div class="larry-form-item">
                                <label class="larry-form-label">真实姓名</label>
                                <div class="larry-input-block">
                                    <input type="text" id="userName" name="userName" autocomplete="off"
                                           class="layui-input larry-input"  th:value="${user?.userName}" readonly="readonly"/>
                                </div>
                            </div>
                            <div class="larry-form-item">
                             <label class="larry-form-label">性别</label>
                                <div class="larry-input-block">
                                    <input type="text" id="userSex" name="userSex" autocomplete="off" class="layui-input larry-input"  th:value="${user?.userSex} == '01' ? '男' : '女'" readonly="readonly"/>
                                </div>
                            </div>
                            <div class="larry-form-item">
                                <input type="hidden" id="oldMobile" name="oldMobile" th:value="${user?.userMobile}"/>
                                <label class="larry-form-label">手机号码</label>
                                <div class="larry-input-block">
                                    <input type="text" id="userMobile" name="userMobile" autocomplete="off"
                                           class="larry-input larry-input" placeholder="输入手机号码"
                                           th:value="${user?.userMobile}" lay-verify="phone"/>
                                </div>
                            </div>
                            <div class="larry-form-item">
                                <input type="hidden" id="oldemail" name="oldemail" th:value="${user?.email}"/>
                                <label class="larry-form-label">邮箱</label>
                                <div class="larry-input-block">
                                    <input type="text" id="email" name="email" autocomplete="off"
                                           class="larry-input larry-input" placeholder="输入邮箱"
                                           th:value="${user?.email}" lay-verify="email"/>
                                </div>
                            </div>
                            <div class="larry-form-item">
                                <div class="larry-input-block">
                                    <a class="layui-btn" lay-submit="" lay-filter="add" >立即提交</a>
                                    <button type="reset" class="larry-btn larry-btn-primary">重置</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </section>
            </div>
        </div>
    </div>
</div>
<!-- 加载js文件-->
<script type="text/javascript" th:src="@{/static/larryms/layui/layui.js}"></script>
<script type="text/javascript" th:inline="javascript">/*<![CDATA[*/
    var bathPath = /*[[@{/}]]*/ "/";
    layui.config({
        version: ui.version,
        base: bathPath + 'static/larryms/',  //实际使用时，建议改成绝对路径
        rightMenu: "none" // false关闭，设置为custom时使用自定义，不使用默认menu
    }).extend({
        larry: 'js/base'
    }).use(['larry', 'jquery', 'form','custom'], function () {
        var $ = layui.$, form = layui.form, larryms = layui.larryms, beone = layui.custom;
        $(function () {
            $("div.larryms-page-body").css({height: ($(window).height() - 150) + "px"});
            form.render();
        })

        //监听提交
        form.on('submit(add)', function (data) {
            var oldMobile = $("#oldMobile");
            var oldemail = $("#oldemail");
            //修改手机号码或者邮箱
            if(oldMobile.val()&&oldemail.val()){
                if(oldMobile.val() == data.field.userMobile&&oldemail.val() == data.field.email){
                    larryms.msg("请修改手机号码或邮箱，再提交！");
                    return false;
                }
            }
            var url = bathPath + 'system/console/saveUser';
            $.post(url, {userMobile:data.field.userMobile,email:data.field.email}, function (res) {
                console.log(JSON.stringify(res));
                if (res.code == "success") {
                    larryms.msg(res.desc);
                    $("#oldMobile").val(data.field.userMobile);
                    $("#oldemail").val(data.field.email);
                }
            });
            return false;
        });
    });

/*]]>*/</script>
</body>
</html>